#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <dinput.h>
#include "Define.h"
#define DIRECTINPUT_VERSION 0x0800
#define KEYBOARD_BUFFER_SIZE 1024
class Directx
{
public:
	Directx(void);
	Directx(HINSTANCE hInstance);
	~Directx(void);
	HINSTANCE _hInstance;
	UINT ncmdShow;
	LPDIRECT3D9 _d3d;
	LPDIRECTINPUT8			di;
	LPDIRECTINPUTDEVICE8		keyboard;
	HWND _hWnd;
	LPDIRECT3DDEVICE9 _d3ddv;
	LPDIRECT3DSURFACE9	_backBuffer;
	LPDIRECT3DSURFACE9	_backGround;
	D3DFORMAT _backBufferFormat;
	LPD3DXSPRITE _spriteHandler;
	BYTE keyStates[256];
	DIDEVICEOBJECTDATA		keyEvents[ KEYBOARD_BUFFER_SIZE ];
	DWORD					dwElements;

public:
	void Init(HINSTANCE hInstance);
	void InitWindow();
	void InitDirectx();
	void InitSpriteHandler();
	void InitKeyBoard();
	void ProcessKeyBoard();
private:
	static LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	void Release();
	
public:
	int	 IsKeyDown(int KeyCode);
	bool BeginScene();
	bool EndScene();
	LPDIRECT3DTEXTURE9 LoadTextureFromFile(char* path,D3DCOLOR transkey);
};